package com.zzgele.qmzb.api.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.zzgele.qmzb.api.core.AbstractService;
import com.zzgele.qmzb.api.dao.WithdrawalsLogMapper;
import com.zzgele.qmzb.api.model.WithdrawalsLog;
import com.zzgele.qmzb.api.service.WithdrawalsLogService;
import com.zzgele.qmzb.api.utils.DateUtil;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;

@Service(interfaceClass = WithdrawalsLogService.class,proxy="jdk")
@Component
@Transactional
public class WithdrawalsLogServiceImpl extends AbstractService<WithdrawalsLog> implements WithdrawalsLogService {

    @Resource
    private WithdrawalsLogMapper withdrawalsLogMapper;
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");


    public BigDecimal getTotalMoneyOneMonth(Long uid){
        // 获取前月的第一天
        Calendar  cale = Calendar.getInstance();
        cale.add(Calendar.MONTH, 0);
        cale.set(Calendar.DAY_OF_MONTH, 1);
        int startTime= DateUtil.getUnixTimeStampByDate(cale.getTime());
        int endTime= DateUtil.getCurUnixTimeStampInt();
        return  withdrawalsLogMapper.getTotalMoneyOneMonth( uid, startTime, endTime) ;
    }
    public List<HashMap> list(Long uid){
        return  withdrawalsLogMapper.list(uid);
    }

}
